//test for isGameOver

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

#define DEBUG 0
#define NOISY_TEST 1

int main () {

  int r;
  int k[10] = {adventurer, council_room, feast, gardens, mine,
	       remodel, smithy, village, baron, great_hall};

  struct gameState G;
  
  r = initializeGame(2, k, 1, &G);

  puts("\n\n********* UNIT TEST 2 - ISGAMEOVER ************\n");
  printf ("initializeGame(2, k, 1, &G) = %d\n", r);
  assert(r == 0);

  //Conditions for game being over:
  //1) if stack of Province cards is empty
  //2) if three supply pile are at 0

  // at beggining province cards and no supply cards are empty

  int over = isGameOver(&G);
  printf("Game over?: %d\n", over );
  assert(over == 0);

  int count = G.supplyCount[province];

  printf("intial province count: %d\n", count); 
  
  G.supplyCount[province] = 0;
  count = G.supplyCount[province];
  printf("province count: %d\n", count); 

  over = isGameOver(&G);
  printf("Game over?: %d\n", over );
  assert(over == 1);

  G.supplyCount[province] = 1;
  count = G.supplyCount[province];
  printf("province count: %d\n", count); 

  over = isGameOver(&G);
  printf("Game over?: %d\n", over );
  assert(over == 0);

  G.supplyCount[province] = 1;
  count = G.supplyCount[province];
  printf("province count: %d\n", count); 

  //empty 3 supply piles
  G.supplyCount[copper] = 0;
  G.supplyCount[silver] = 0;
  G.supplyCount[gold] = 0;
  printf("three supply piles emptied\n" );

  over = isGameOver(&G);
  printf("Game over?: %d\n", over );
  assert(over == 1);

  printf("testIsGameOver: PASS\n" );







  
  return 0;
}
